package com.nondo.rdp.core.domain;

import com.nondo.rdp.core.domain.base.BaseEntity;

import javax.persistence.*;

/**
 * 规则表
 */
@Entity
@Table(name = "common_rules")
public class Rules extends BaseEntity {
    private Long id;    //自增ID
    private String name;// 规则展示名字
    private String type;// 类型
    private String value;// 值 5
    private int open;// 是否启用 0=启用，1=关闭
    private String js;// 规则脚本
    private boolean openCheck; //方便后端处理

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    @Column(columnDefinition = "int default 0")
    public int getOpen() {
        return open;
    }

    public void setOpen(int open) {
        this.open = open;
    }

    public String getJs() {
        return js;
    }

    public void setJs(String js) {
        this.js = js;
    }

    @Transient
    public boolean getOpenCheck() {
        if (this.open == 0) {
            return true;
        }
        return false;
    }

    public void setOpenCheck(boolean openCheck) {
        this.openCheck = openCheck;
        if (openCheck == true) {
            this.open = 0;
        } else {
            this.open = 1;
        }
    }
}
